import Taro, { Component, Config } from '@tarojs/taro'
import '@tarojs/async-await'
import { Provider } from '@tarojs/redux'

import Index from './pages/index'

import configStore from './store'

import './app.less'

const store = configStore()

class App extends Component {
  /**
   * 指定config的类型声明为: Taro.Config
   *
   * 由于 typescript 对于 object 类型推导只能推出 Key 的基本类型
   * 对于像 navigationBarTextStyle: 'black' 这样的推导出的类型是 string
   * 提示和声明 navigationBarTextStyle: 'black' | 'white' 类型冲突, 需要显示声明类型
   */
  config: Config = {
    pages: [
      'pages/controlCar/index',
      'pages/index/index',
      'pages/indexold/index',
      'pages/mine/index',
      'pages/login/index'
    ],
    window: {
      backgroundTextStyle: 'light',
      navigationBarBackgroundColor: '#fff',
      navigationBarTitleText: 'WeChat',
      navigationBarTextStyle: 'black'
    },
    tabBar: {
      "list": [{
        "pagePath": "pages/controlCar/index",
        "text": "控车",
        iconPath: './assets/images/flashlight.png',
        selectedIconPath: './assets/images/flashlight_fill.png',
      }, {
        "pagePath": "pages/index/index",
        "text": "位置",
          iconPath: './assets/images/coordinates.png',
          selectedIconPath: './assets/images/coordinates_fill.png',
      }, {
        "pagePath": "pages/indexold/index",
        "text": "消息",
          iconPath: './assets/images/interactive.png',
          selectedIconPath: './assets/images/interactive_fill.png',
      }, {
        "pagePath": "pages/mine/index",
        "text": "我的",
          iconPath: './assets/images/people.png',
          selectedIconPath: './assets/images/people_fill.png',
      }],
      backgroundColor: '#fff',
      borderStyle: 'black',
      selectedColor: '#6190e8'
    }
  }

  componentDidMount() { }

  componentDidShow() { }

  componentDidHide() { }

  componentCatchError() { }

  render() {
    return (
      <Provider store={store}>
        <Index />
      </Provider>
    )
  }
}

Taro.render(<App />, document.getElementById('app'))
